﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using connect;

namespace Pharmacy_management_system
{
    public partial class dian_ping_ren : DevExpress.XtraEditors.XtraForm
    {
        public dian_ping_ren()
        {
            InitializeComponent();
        }
        public static string checkyes = "";
        public void showuserdata()
        {
            string connectionstring = @"server=.;database=PASS;Integrated Security=True";
            SqlConnection con = new SqlConnection();
            con.ConnectionString = connectionstring;
            string cmdText = "select a.emp_sn as 编号,b.name as 姓名 from sys_sys_users a,dict_employee b where a.emp_sn=b.emp_sn order by a.emp_sn";
            SqlDataAdapter da = new SqlDataAdapter(cmdText, con);
            DataSet ds = new DataSet();
            con.Open();
            da.Fill(ds);
            dataGridView1.DataSource = ds.Tables[0].DefaultView;
            con.Close();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //刷新
            if (dataGridView1.IsCurrentCellDirty)
            {
                dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit);
            }
            //取得选中的行
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (Convert.ToString(dataGridView1.Rows[i].Cells["Column1"].Value) == "True")
                {
                    //相应的操作
                    string row3 = dataGridView1.Rows[i].Cells[2].Value.ToString();//获取选中行的第三列的值
                    checkyes = checkyes +row3 + ",";

                }
                Form1.yonghu = checkyes;
            }
            checkyes = "";
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dian_ping_ren_Load(object sender, EventArgs e)
        {
            showuserdata();
        }
    }
}